/**
 * Test algorithms for JettHoughts
 * 
 * Created 12/02/2012
 * 
 * @author Vasili Svirski
 * @version 0.01
 */

package com.jetthoughts.algorithms;

import java.util.ArrayList;

/**
 * 
 * Check list of words on poliandr
 *
 */
public class Poliandr {

	public static ArrayList<String> isPoliandr(ArrayList<String> input) {
		
		ArrayList<String> resArrayList = new ArrayList<>();
		
		for(int index = 0; index < input.size(); index++){
			char words[] = input.get(index).toCharArray();
			int length =  words.length;
			boolean poliandrFlag = true;

			for (int i = 0, j = (length - 1); i < (length / 2); i++, j--) 
			{
				if (words[i] != words[j])
					poliandrFlag  = false;
			}

			if (poliandrFlag == true)
				resArrayList.add(input.get(index).toLowerCase());
		}
		
		return resArrayList;
	}
}
